//
//  MeatMeSurveyTableViewCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/3.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatMeSurveyTableViewCell.h"

@implementation MeatMeSurveyTableViewCell

#pragma mark - lifecycle methods

- (void)setupUI
{
    [self.contentView addSubview:self.icon];
    [self.contentView addSubview:self.nameLab];
    [self.contentView addSubview:self.detalLab];
    [self.contentView addSubview:self.sumbitBtn];
}

- (void)setupLayout
{
    {
        _icon.size = CGSizeMake(45, 45);
        _icon.mj_x = 15;
        _icon.mj_y = 15;
    }
    
    {
        _nameLab.size = CGSizeMake(100, 20);
        _nameLab.mj_x = _icon.right + 12;
        _nameLab.mj_y = 15;
    }
    
    {
        _detalLab.size = CGSizeMake(150, 20);
        _detalLab.mj_x = _icon.right + 12;
        _detalLab.mj_y = 40;
    }
    
    {
        _sumbitBtn.size = CGSizeMake(56, 27);
        _sumbitBtn.mj_y = 24;
        _sumbitBtn.mj_x = KScreenWidth - 45 - _sumbitBtn.width;
    }
    
}

#pragma mark - setter methods

- (void)setItem:(TaskDataModel *)item{
    
    if ([item.verification integerValue] == 0) {
        
        [_sumbitBtn setTitle:@"已认证" forState:UIControlStateNormal];
        [_sumbitBtn setBackgroundImage:nil forState:UIControlStateNormal];

    }else{
        
        [_sumbitBtn setTitle:@"去完成" forState:UIControlStateNormal];
        [_sumbitBtn setBackgroundImage:[UIImage imageNamed:@"user_myasset_bg"] forState:UIControlStateNormal];
    }
    
    _detalLab.text = [NSString stringWithFormat:@"完成获得豚券 +%@", item.coupon];
}


#pragma mark - getter methods

- (UIImageView *)icon{
    
    if (!_icon) {
        _icon = [UIImageView new];
        _icon.image = [UIImage imageNamed:@"user_myasset_rewards"];
    }
    return _icon;
}


- (UILabel *)nameLab{
    
    if (!_nameLab) {
        _nameLab = [UILabel makeLabelWithText:@"问卷调查" textColor:mMainTextColor font:mFont(16) textAliment:0];
    }
    return _nameLab;
}

- (UILabel *)detalLab{
    
    if (!_detalLab) {
        _detalLab = [UILabel makeLabelWithText:@"完成获得豚券 +5" textColor:UIColorFromRGB(0x9B9B9B) font:mFont(13) textAliment:0];
    }
    return _detalLab;
}

- (UIButton *)sumbitBtn{
    
    if (!_sumbitBtn) {
        
        _sumbitBtn = [UIButton makeButtonWithText:@"去完成" textColor:KWhiteColor font:mFont(12) textAliment:1 cornerRadius:13.5];
        [_sumbitBtn setBackgroundImage:[UIImage imageNamed:@"user_myasset_bg"] forState:UIControlStateNormal];
        _sumbitBtn.backgroundColor = UIColorFromRGB(0xEBEBEB);
    }
    return _sumbitBtn;
}


@end
